// [[ OnflowGenerator File UUID: a018ac4db70f4424bed420a2f5448e94  ]]
package com.itdct.onflow.system.configuration.controller

import com.itdct.onflow.core.annotation.ApiParam
import com.itdct.onflow.core.type.*
import com.itdct.onflow.core.vo.KeyLabelValueVo
import com.itdct.onflow.core.vo.RespPageVo
import com.itdct.onflow.core.vo.RespVo
import com.itdct.onflow.system.common.base.BaseSysController
import com.itdct.onflow.system.common.base.ImportExcelQo
import com.itdct.onflow.system.configuration.qo.SysConfigurationEditQo
import com.itdct.onflow.system.configuration.qo.SysConfigurationSearchQo
import com.itdct.onflow.system.configuration.service.SysConfigurationService
import com.itdct.onflow.system.configuration.vo.SysConfigurationDetailVo
import com.itdct.onflow.system.configuration.vo.SysConfigurationListVo
import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.tags.Tag
import org.springframework.http.MediaType
import org.springframework.validation.annotation.Validated
import org.springframework.web.bind.annotation.*

/**
 * @author DCTANT
 * @date 2025-09-01 14:24:40
 * @version 1.0
 * @description 系统配置接口控制
 */
@Tag(name = SysConfigurationController.moduleName)
@RestController
@RequestMapping(value = ["/sysConfiguration"], produces = [MediaType.APPLICATION_JSON_VALUE], method = [RequestMethod.POST])
class SysConfigurationController(
    val sysConfigurationService: SysConfigurationService
) : BaseSysController() {
    companion object {
        const val moduleName = "系统配置"
    }

    @ApiParam(important = true)
    @Operation(summary = moduleName + "添加")
    @PostMapping("/add.adw")
    fun add(@RequestBody @Validated(Add::class) qo: SysConfigurationEditQo): RespVo<Long> {
        return sysConfigurationService.add(qo, getContext())
    }

    @ApiParam(important = true)
    @Operation(summary = moduleName + "更新")
    @PostMapping("/update.adw")
    fun update(@RequestBody @Validated(Update::class) qo: SysConfigurationEditQo): RespVo<Unit> {
        return sysConfigurationService.update(qo, getContext())
    }

    @ApiParam(important = true)
    @Operation(summary = moduleName + "删除")
    @PostMapping("/delete.adw")
    fun delete(@RequestBody @Validated(Delete::class) qo: SysConfigurationEditQo): RespVo<Unit> {
        return sysConfigurationService.delete(qo, getContext())
    }

    @Operation(summary = moduleName + "详情")
    @PostMapping("/detail.adw")
    fun detail(@RequestBody @Validated(Detail::class) qo: SysConfigurationSearchQo): RespVo<SysConfigurationDetailVo> {
        return sysConfigurationService.detail(qo, getContext())
    }

    @Operation(summary = moduleName + "列表")
    @PostMapping("/page.adw")
    fun page(@RequestBody @Validated(Page::class) qo: SysConfigurationSearchQo): RespPageVo<SysConfigurationListVo> {
        return sysConfigurationService.page(qo, getContext())
    }

    @Operation(summary = moduleName + "所有配置信息")
    @PostMapping("/allConfig.adw")
    fun allConfig(@RequestBody qo: SysConfigurationSearchQo): RespVo<Map<String, String>> {
        return sysConfigurationService.allConfig(qo, getContext())
    }

    @Operation(summary = moduleName + "导出")
    @PostMapping("/export.adw")
    fun export(@RequestBody qo: SysConfigurationSearchQo): RespVo<Unit> {
        return sysConfigurationService.export(qo, getContext())
    }

    @Operation(summary = moduleName + "导入")
    @PostMapping("/import.adw")
    fun import(@Validated qo: ImportExcelQo): RespVo<Unit> {
        return sysConfigurationService.import(qo, getContext())
    }

    // [[ OnflowGenerator Range (- selectFunctions -) Start ]]
    @Operation(summary = moduleName + "配置键下拉选")
    @PostMapping("/selectConfigKeyList.adw")
    fun selectConfigKeyList(@RequestBody qo: SysConfigurationSearchQo): RespVo<List<KeyLabelValueVo>> {
        return sysConfigurationService.selectConfigKeyList(qo, getContext())
    }

// [[ OnflowGenerator Range (- selectFunctions -) End ]]
}